package com.jsoft.model;

import com.jsoft.dto.MenuGroupDto;
import com.jsoft.model.core.BaseDao;

import javax.persistence.*;
import java.util.List;

/**
 * Date: 26.09.13
 * Time: 17:52
 */

@Entity
@Table(name = "menu_groups")
public class MenuGroupDao extends BaseDao {
    @Column(name = "name")
    private String name;
    @OneToMany(mappedBy = "menuGroup")
    private List<MenuItemDao> menuItems;
    @ManyToOne(fetch = FetchType.LAZY)
    private MenuDao menu;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<MenuItemDao> getMenuItems() {
        return menuItems;
    }

    public void setMenuItems(List<MenuItemDao> menuItems) {
        this.menuItems = menuItems;
    }

    public MenuDao getMenu() {
        return menu;
    }

    public void setMenu(MenuDao menu) {
        this.menu = menu;
    }

    public MenuGroupDto wrapMenuGroupDto() {
        MenuGroupDto dto = new MenuGroupDto();
        dto.setId(this.getObjectId());
        dto.setName(this.getName());
        return dto;
    }

    public MenuGroupDao wrapMenuGroupDao(MenuGroupDto dto) {
        MenuGroupDao dao = new MenuGroupDao();
        dao.setName(dto.getName());
        return dao;
    }
}
